﻿using Point24.Core;
using System;
using System.Windows.Forms;
using System.Linq;
using System.Collections.Generic;

namespace Point24.WinForm
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void btnCacutor_Click(object sender, EventArgs e)
        {
            int[] array = { (int)number1.Value, (int)number2.Value, (int)number3.Value, (int)number4.Value };
            var expressionList = Caculator.Point24(array);
            if (expressionList != null)
            {
                lbResult.Items.Clear();
                foreach (var expression in expressionList)
                {
                    lbResult.Items.Add($"方案{(expressionList.IndexOf(expression) + 1)}：{expression}");
                }
                if (expressionList.Count > 0)
                {
                    Clipboard.SetText(string.Join(Environment.NewLine, expressionList));
                }
            }
            lbResult.Items.Add($"总共方案数量：{expressionList?.Count}");
        }
    }
}
